package com.xhwl.centiotdata.pojo.dto.visitor;

import com.alibaba.fastjson.JSONObject;
import com.xhwl.common.pojo.cent.device.DeviceProjSupplierCategory;
import lombok.Data;

import java.util.Objects;

/**
 * @Author: yanyixiong
 * @Description:
 * @Date: create in 17:59 2022/3/7
 */
@Data
public class VisitorIntegrationConfigDTO {

    private Integer projectId;

    private Integer productId;

    private String ipAndPort;

    private String loginName;

    private String password;

    private String token;

    private String ak;

    private String sk;

    private String tagId;

    public static VisitorIntegrationConfigDTO toVisitorIntegrationConfig(DeviceProjSupplierCategory supplierCategory){
        VisitorIntegrationConfigDTO dto = new VisitorIntegrationConfigDTO();
        JSONObject properties = supplierCategory.getProperties();
        if(Objects.nonNull(properties)){
            dto = properties.toJavaObject(VisitorIntegrationConfigDTO.class);
        }
        dto.setProductId(supplierCategory.getProductId());
        dto.setProjectId(supplierCategory.getProjectId());
        return dto;
    }


}
